import E from 'wangeditor';
const { $, BtnMenu } = E;
var _this = null;

export default class HtmlMenu extends BtnMenu {
  constructor(editor) {
    _this = editor;
    const $elem = E.$(
      `<div class="w-e-menu" data-title="html">
                <div>HTML</div>
            </div>`,
    );
    super($elem, editor);
  }

  clickHandler() {
    const editor = _this;
    const html = editor.txt.html();
    // 这里可以添加HTML编辑功能，比如弹出模态框编辑HTML
    const newHtml = prompt('编辑HTML', html);
    if (newHtml !== null) {
      editor.txt.html(newHtml);
    }
  }

  tryChangeActive() {
    this.active();
  }
}
